package com.wzy.netty.nio;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * 描述
 * 创建人    Wzy
 * 创建时间: 2020-05-20  14:10
 */
public class NIOFileChannel02 {
    public static void main(String[] args) throws IOException {
        File file = new File("d:\\file01.txt");
        FileInputStream fileInputStream = new FileInputStream(file);
        FileChannel channel = fileInputStream.getChannel();

        ByteBuffer byteBuffer = ByteBuffer.allocate((int) file.length());

        int read = channel.read(byteBuffer);
        System.out.print(new String(byteBuffer.array()));
        fileInputStream.close();


    }
}
